#include <stdio.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>

int main()
{
	pid_t id = fork();

	if(id == 0)
	{
		int cnt = 5;
		while(cnt--)
		{
			printf("这是一条子进程,id为:%d,父进程id:%d\n",getpid(),getppid());
		}
		exit(11);
	}
	else if(id > 0)
	{
		int status = 0;
		waitpid(id,&status,0);
		printf("exit code : %d , exit signal : %d\n",(status >>8) & 0xFF,status & 0x7F );

		//printf("exit code : %d , exit signal : %d\n",(status >>8) ,status & 0x7F );
	}

	return 0;
}
